
#include <config.h>
#include <klib.h>

#ifndef __MM_H
#  define __MM_H

extern uint8 _error_code;

#  define _MM_NO_MEM      0x1
#  define _MM_CORRUPTION  0x2

struct __mm_table_entry {

  void *addr;
  size_t len;

};

struct __mm_hash_table {

  void *start;
  size_t entries;
  size_t capacity;

};

struct __mm_addr_space {

  void *base;
  size_t table_len;
  size_t limit;

};

typedef struct __mm_hash_table __mm_hash_table;

void *mm_malloc(size_t);
void  mm_free(void *);

uint32 _mm_hash(__mm_hash_table *, void *);
int    _mm_extend_table(__mm_hash_table *, int);

#endif
